#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    pushbutton = new QPushButton(this);
    pushbutton->setText("按钮1");

    connect(pushbutton,&QPushButton::clicked,this,&Widget::HandlerClieck);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::HandlerClieck()
{
    this->setWindowTitle("这是第一个标题");
}

void Widget::HandlerClieck2()
{
    this->setWindowTitle("这是第二个标题");
}


void Widget::on_pushButton_clicked()
{
    disconnect(pushbutton,&QPushButton::clicked,this,&Widget::HandlerClieck);

    connect(pushbutton,&QPushButton::clicked,this,&Widget::HandlerClieck2);
}
